<template>
  <el-switch
      v-bind="$attrs"
      v-model="state.paramVal"
      :disabled="isValue($attrs.disabled) ? $attrs.disabled : state.formView"
  />
</template>

<script setup lang="ts">
import {
  reactive,
  watch,
  inject
} from 'vue'
import {isValue} from "@/utils/czr-util";
const emit = defineEmits(['emitParam'])
const props = defineProps({
  param: {},
  label: {},
})
const state = reactive({
  paramVal: props.param,
  formView: inject('form-view', false),
})
watch(() => state.paramVal, (n) => {
  emit('emitParam', n)
})
watch(() => props.param, (n) => {
  state.paramVal = n
})
</script>

<style scoped lang="scss">
</style>
